/*
 * @Title: 订单支付成功
 * @Author: JSL、zhuhaojie
 * @Date:   2018-10-13
 * @Last Modified by:   JSL
 * @Last Modified time: 2018-10-16
 */

var dataInfo = new Object(),
	template = {
		init: function() {
			Vue.use(VueLazyload, {
				preLoad: 1.3,
				error: 'https://h5.meetao.com/img/product/init.png',
				loading: 'https://h5.meetao.com/img/product/init.png',
				attempt: 1
			});
			dataInfo.init = new Vue({
				el: '#app',
				data: {
					orderInfo: {
						payChannel: '',
						orderAmount: '',
						amount: '',
					},
					orderId: getQueryString('orderId'),
					hot: [], //热卖商品、推荐商品集合
					isFx: 1,
					isDz: 0,
				},
				methods: {
					getOrderInfo: function() { //获取订单数据
						ajaxTemplate(addressUrl + SERVICE.getOrderInfo, function(data) {
							log(data);
							if(data.tag == 0) {
								dataInfo.init.orderInfo = data.data.result[0];
							} else {
								dataInfo.init.$toast(data.errMsg);
							};
						}, {
							userId: userId,
							orderId: this.orderId
						});
					},
					backHome: function() {
						location.href = '../html/index.html';
					},
					toOrderDetails: function() {
						location.href = '../html/orderDetails.html?orderId=' + this.orderId;
					},
					recommendGoods: function() { // 推荐商品
						ajaxTemplate(addressUrl + SERVICE.queryGoodsRecommend, function(data) {
							console.log(data);
							if(data.tag == 0) {
								var daTa = data.data.result;
								daTa.forEach(function(item, index) {
									if(item.isKill !== 0) {
										dataInfo.init.hot.push(item);
									};
								});
							} else {
								dataInfo.init.$toast(data.errMsg);
							};
						}, {});
					},
					toProduct:function(data){
						jumpProductDetails(data);
					},
				},
			});
			dataInfo.init.getOrderInfo();
			dataInfo.init.recommendGoods();
		},
	};

template.init();